import java.util.*;

public class StudentMap {

    public static void main(String[] args) {
        // 创建学生表
        Map<String, String> studentMap = new HashMap<>();
        studentMap.put("001", "李志杰");
        studentMap.put("002", "黄俊翔");
        studentMap.put("003", "周俊杰");
        studentMap.put("004", "郑荣锦");

        // 遍历学生信息
        System.out.println("\n学号和姓名是： ");
        studentMap.forEach((ID, name) -> System.out.println(ID + "：" + name + "  "));

        // 根据学号查询学生信息
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入查询的学号：");
        String id = scanner.next();
        String name = studentMap.get(id);
        if (name != null) {
            System.out.println("\n查询结果为：" + name);
        } else {
            System.out.println("\n查询结果为：没有找到该学号的学生");
        }
    }
}
